<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2020/10/15
  Time: 17:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>

    <script>

        var obj1 = {"name": "刘备xx", "age": 23, "address": "广东深圳", "vip": false};
        var obj2 = '{"name":"刘备","age":23,"address":"广东深圳","vip":false}';


        alert(obj1);
        alert(obj2);

        alert(obj1.name);
        alert(obj2.name);

        //json字符串转为json对象
        var obj3 = JSON.parse(obj2);
        alert(obj3.name);

        //json对象转为json字符串
        var obj4 = JSON.stringify(obj1);
        alert(obj4);

        //只有是对象，我们才可以操作里面的属性值。不然就是一个String

    </script>
</head>
<body>

</body>
</html>
